import {defineStore} from 'pinia'
import {LoginFormType} from '@/types/login'
import api from '@/api'
const useLoginStore=defineStore('login',{
    state(){
        return{
           user:JSON.parse(localStorage.getItem('user')!)||{}
        }
    },
    actions:{
        async loginAsync(data:LoginFormType){
            console.log('--------进入到登录的异步方法------------');
            const result=await api.loginModule.loginApi(data)
            console.log('result',result);
            this.user=result.data.data
            localStorage.setItem('user',JSON.stringify(result.data.data))
            return result.data.code
        }
    }
})
export default useLoginStore